aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/article/[slug].tsx
Commit message (Collapse)AuthorAgeFilesLines
* fix(pages): use dynamic imports for the table of contentsArmand Philippot2023-12-181-3/+11
| | | | | | | The ToCWidget relies on Javascript to display the headings. If JS is disabled in the browser, the widget is empty. For a better UX, we should use dynamic imports. Now, the ToC is only displayed when JS is enabled.
* fix(build): handle Next.js errors and warnings during buildArmand Philippot2023-12-161-7/+12
| | | | | | | | | | | | * extract Blog component from BlogPage (paginated) and extract Article component from ArticlePage to avoid `Cannot read properties` errors due to fallback route * fix sitemap build (cjs not supported) * fix eslint warnings (react/jsx-no-literals) * update `start` script since I'm using standalone output * update `postbuild` script since we need to copy public and static files to standalone directory (Next.js does not handle it itself because we should use a CDN...)
* refactor(pages): rewrite helpers to output schema in json-ld formatArmand Philippot2023-12-141-44/+56
| | | | | | | | | | | | | * make sure url are absolutes * nest breadcrumb schema in webpage schema * trim HTML tags from content/description * use a regular script instead of next/script (with the latter the schema is not updated on route change) * place the script in document head * add keywords, wordCount and readingTime keys in BlogPosting schema * fix breadcrumbs in search page (without query) * add tests (a `MatchInlineSnapshot` will be better but Prettier 3 is not supported yet)
* refactor(hooks): rewrite useBreadcrumbs hookArmand Philippot2023-12-121-11/+5
| | | | | | | * use next/router to get the slug instead of using props * handle cases where the current page title is not provided * update JSON-LD schema to match the example in documentation * add tests
* refactor(pages): refine Project pagesArmand Philippot2023-12-081-1/+1
| | | | | | | | | | | * refactor ProjectOverview component to let consumers handle the value * extract project overview depending on Github to avoid fetching Github API if the project is not on Github * wrap dynamic import in a useMemo hook to avoid infinite rerender * fix table of contents by adding a useMutationObserver hook to refresh headings tree (without it useHeadingsTree is not retriggered once the dynamic import is done) * add Cypress tests
* refactor(pages): refine Article pagesArmand Philippot2023-12-011-131/+96
| | | | | | | | | | | * use rehype to update code blocks class names * fix widget heading level (after a level 1 it should always be a level 2 and not 3) * replace Spinner with LoadingPage and LoadingPageComments components to keep layout coherent * refactor useArticle and useComments hooks * fix URLs in JSON LD schema * add Cypress tests
* refactor(services): avoid nested fetchersArmand Philippot2023-11-281-1/+3
| | | | | | | If we use fetchPostsCount inside fetchAllPostsSlugs, we might have problems to test fetchAllPostsSlugs failure. So it is better to let the consumer pass the posts count as an argument. The same applies to thematics and topics.
* refactor(services, types): reorganize GraphQL fetchers and data typesArmand Philippot2023-11-271-16/+23
| | | | | | | | | | | | The Typescript mapped types was useful for autocompletion in fetchers but their are harder to maintain. I think it's better to keep each query close to its fetcher to have a better understanding of the fetched data. So I: * colocate queries with their own fetcher * colocate mutations with their own mutator * remove Typescript mapped types for queries and mutations * move data convertors inside graphql services * rename most of data types and fetchers
* refactor(components): replace PageLayout template with PageArmand Philippot2023-11-201-137/+79
| | | | | | | | | * split pages in smaller components (it is both easier to maintain and more readable, we avoid the use of fragments in pages directory) * extract breadcrumbs from article tag (the navigation is not related to the page contents) * remove useReadingTime hook * remove layout options except `isHome`
* refactor(components): extract MetaItem from MetaListArmand Philippot2023-11-201-99/+95
| | | | | | * replace `items` prop on MetaList with `children` prop: it was too restrictive and the global options was not really useful. It is better too give control to the consumers.
* refactor(hooks): remove useSettings hookArmand Philippot2023-11-151-9/+8
| | | | | | | It does not make sense to re-export an existing object through a hook. On some pages both the hook and the object was imported... It is better to use the CONFIG (previously settings) object directly and by doing it we avoid potential errors because of conditional hooks.
* refactor(components): replace Sharing with SharingWidget componentArmand Philippot2023-11-141-2/+9
| | | | | | | * all the widgets should have a coherent name * fix mailto uri * remove useless CSS * add tests
* refactor(components): rewrite CommentsList componentArmand Philippot2023-11-111-1/+15
| | | | | | * use ApprovedCommentProps to make CommentData type * add the author name of the parent on reply form heading * add tests
* refactor(components): split Comment component into 3 componentsArmand Philippot2023-11-111-1/+31
| | | | | | | | | * add ApprovedComment, PendingComment and ReplyCommentForm components * let consumer handle reply form visibility * move structured data into article page (each article already has the comments data and already handle json ltd schema so I prefered to move the schema in the final consumer instead of adding a script element foreach comment)
* refactor(components): rewrite Code component and usePrism hookArmand Philippot2023-11-111-8/+20
| | | | | | | | | | | | * move Prism styles to Sass placeholders to avoid repeats * let usePrism consumer define its plugins (remove default ones) * remove `plugins` prop from Code component * add new props to Code component to let consumer configure plugins (and handle plugin list from the given options) However there are some problems with Prism plugins: line-highlight and treeview does not seems to be loaded. I don't want to use Babel instead of SWC so I have no solution for now.
* feat(components): add a Time componentArmand Philippot2023-11-111-15/+3
| | | | | | Instead of using helpers functions to format the date each time we need to use a time element, it makes more sense to create a new component dedicated to this task.
* refactor(components): replace Meta component with MetaListArmand Philippot2023-11-111-25/+102
| | | | | | It removes items complexity by allowing consumers to use any label/value association. Translations should also be defined by the consumer. Each item can now be configured separately (borders, layout...).
* refactor(components): replace ResponsiveImage with Figure componentArmand Philippot2023-11-111-2/+2
| | | | | | | | The styles applied to ResponsiveImage are related to the figure and figcaption elements. Those elements could be use with other contents than images. So I extracted them in a Figure component. The ResponsiveImage component is no longer useful: the consumer should use the Image component from `next` and wrap it in a link if needed.
* refactor(components): rewrite Spinner componentArmand Philippot2023-10-241-1/+6
| | | | | | | * Message should be set as children * Default message is no longer available (depending on use case, the consumer might prefer aria-label instead) * It is now possible to define the message position
* refactor(components): rewrite Button and ButtonLink componentsArmand Philippot2023-10-241-8/+6
| | | | | | | | | | | | | | Both: * move styles to Sass placeholders Button: * add `isPressed` prop to Button * add `isLoading` prop to Button (to differentiate state from disabled) ButtonLink: * replace `external` prop with `isExternal` prop * replace `href` prop with `to` prop
* refactor(routes): replace hardcoded routes with constantsArmand Philippot2023-10-241-32/+33
| | | | | | | | It makes it easier to change a route if needed and it avoid typo mistakes. I also refactored a bit the concerned files to be complient with the new ESlint config. However, I should rewrite the pages to reduce the number of statements.
* refactor: use named export for everything except pagesArmand Philippot2023-09-201-20/+22
| | | | | | Next expect a default export for pages so only those components should use default exports. Everything else should use named exports to reduce the number of import statements.
* refactor(build): replace paths aliases with relative pathsArmand Philippot2023-09-191-26/+28
| | | | | | Using paths aliases starting with "@" can be confusing and can lead to conflict with existings modules. I prefer to use relative paths to avoid extra configuration in tools because of these aliases.
* fix(comments): load all comments on a postArmand Philippot2022-08-211-4/+4
| | | | | | | | | Previously, only the first 10 comments was loaded. So I update the fetching method to retrieve all the comments on a post. Also, I choose to order comments on client side because of a bug with WPGraphQL. Finally, I renamed the Comment type to SingleComment to avoid conflict with existing types.
* fix(article): prevent TypeError on buildArmand Philippot2022-07-231-3/+6
| | | | | | By switching to custom hooks for revalidating articles and comments, everything was working on development mode but articles failed to build for production.
* refactor(article): wrap useSWR with a custom hook to revalidate articleArmand Philippot2022-07-221-5/+3
|
* fix(comments): refresh comments on changes or new commentArmand Philippot2022-07-221-3/+2
|
* chore: handle article fallback and revalidationArmand Philippot2022-05-241-25/+26
| | | | | | By using useSWR I can fetch the changes from the backend. By using fallback, I can access new articles without rebuilding the entire app.
* fix: ensure all topics/thematics have the base urlArmand Philippot2022-05-231-6/+2
|
* refactor(schema): use helpers function to avoid repeat between pagesArmand Philippot2022-05-231-58/+36
|
* refactor: reduce the number of data transformationArmand Philippot2022-05-231-36/+7
|
* chore: update some stylesArmand Philippot2022-05-211-4/+1
| | | | | | | * Improve wp-blocks-columns, wp-block-quote and some images * Make Sharing widget consistent between pages * Remove margin option from lists * Fix Topic logo alignement
* refactor: rewrite Prism hooks and providersArmand Philippot2022-05-191-14/+40
| | | | | It avoid some hydratation errors on project pages (not in article however) and the hooks are now reusable.
* chore: use persistent layoutArmand Philippot2022-05-171-3/+13
| | | | | It prevents to rerender the common components between pages (header, footer...).
* chore: adjust articles stylesArmand Philippot2022-05-171-2/+16
| | | | | * change animation on article card hover * change comments section alignment
* chore: adjust and complete missing stylesArmand Philippot2022-05-161-4/+39
| | | | | | * add logo to topics pages and links * add Prism styles to articles * and a few other adjustements
* refactor: use custom hook for breadcrumb items and schemaArmand Philippot2022-05-161-18/+6
|
* chore: add Article pagesArmand Philippot2022-05-151-0/+251
|
* chore: remove old pages, components, helpers and typesArmand Philippot2022-04-291-291/+0
| | | | | Since I'm using new components, I will also rewrite the GraphQL queries so it is easier to start from scratch.
* refactor: load prism plugins without babelArmand Philippot2022-03-241-15/+43
|
* refactor: use formatjs swc pluginArmand Philippot2022-03-231-0/+7
| | | | | I'm not able to configure SWC plugins in Next.js so to make it works, all translation must have an id.
* refactor: split posts meta into smaller componentsArmand Philippot2022-03-011-2/+2
|
* refactor: replace script tags with next/script (#10)Armand Philippot2022-02-211-4/+6
| | | | | | | | * refactor: replace script tags with next/script Since next.js v12.1.0 some warnings was displayed because I was using some script tags. * build(deps): bump next-themes to v0.1.1
* fix: make schema.org markup valid (#4)Armand Philippot2022-02-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Squashed commit of the following: commit 49c1b3b1556a0eb91c429a961fedd2bded8ffd47 Author: Armand Philippot <git@armandphilippot.com> Date: Wed Feb 16 15:17:52 2022 +0100 chore: add headline field to blogPosting schema commit 42214c6f032cc899ec252a9387be35dcad738546 Author: Armand Philippot <git@armandphilippot.com> Date: Wed Feb 16 15:09:11 2022 +0100 chore: update the searchAction markup and add query-input Google was complaining about "query-input" which is not in Schema.org representation. So I added it. commit 5f29226d937cbdcd262df2793f1588435d850f02 Author: Armand Philippot <git@armandphilippot.com> Date: Wed Feb 16 14:32:14 2022 +0100 chore: remove breadcrumb from homepage The breadcrumb is not displayed on the homepage, so the breadcrumb field should not appear inside Schema markup.
* fix: update comments list when a new comment is sendArmand Philippot2022-02-141-5/+14
| | | | | The comments list was static before. If an user posted a comment, even after it was approved, the comments list was keeping the old state.
* fix: switch prism theme on single articleArmand Philippot2022-02-131-1/+1
| | | | I forgot to change the selector to query all code blocks.
* chore: update some texts to reduce its widthArmand Philippot2022-02-131-2/+2
| | | | | | | In French, "Utiliser le thème sombre" was a little too long, so instead I decided to remove the "Toggle" word and add an icon to help user understand the button purpose. Same way, "Aucune étoile" was too long, so I replace it with "0 étoile"
* chore: improve accessibilityArmand Philippot2022-02-111-2/+14
|
* fix(prism): translate toolbar buttons on single article pagesArmand Philippot2022-02-101-12/+31
| | | | | The translation was not always loaded the first time. So I decided to put the prism attributes manually instead.
* chore(prism): translate color scheme toggle buttonArmand Philippot2022-02-081-1/+6
|